﻿// <copyright file="ShareVia.cs" company="Microsoft Corporation">
// Copyright (c) 2009 Microsoft Corporation All Rights Reserved
// </copyright>
// <author>Michael S. Scherotter</author>
// <email>mischero@microsoft.com</email>
// <date>2010-09-13</date>
// <summary>Share via an internet site/service</summary>

namespace MostPopular.ViewModels
{
    using System.ComponentModel;

    /// <summary>
    /// Share via an internet site or service
    /// </summary>
    public class ShareVia : INotifyPropertyChanged
    {
        /// <summary>
        /// is this sharing mechanism enabled
        /// </summary>
        private bool isEnabled;

        #region INotifyPropertyChanged Members

        /// <summary>
        /// Property changed event handler
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;

        #endregion

        /// <summary>
        /// Gets or sets the Id of the service
        /// </summary>
        public string Id { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether this sharing mechanism is enabled
        /// </summary>
        public bool IsEnabled 
        { 
            get
            {
                return this.isEnabled;
            }

            set
            {
                if (this.isEnabled != value)
                {
                    this.isEnabled = value;

                    this.TriggerPropertyChanged("IsEnabled");
                }
            }
        }

        /// <summary>
        /// Gets or sets the human-readable name of this mechanism
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// Trigger the property changed notification
        /// </summary>
        /// <param name="propertyName">the property name</param>
        private void TriggerPropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
